<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link rel="stylesheet" href="./layui/css/layui.css">
</head>
<body>
<h2 align="center">发帖</h2>
<form class="layui-form">

<div class="layui-form-item layui-form-text">
    <label class="layui-form-label">留言类容</label>
    <div class="layui-input-block">
        <textarea name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
</div>
<div class="layui-form-item">
    <div class="layui-input-block">
        <button class="layui-btn" lay-submit lay-filter="sub">提交</button>
    </div>
</div>
    </form>
</body>
</html>
<script src="./layui/layui.js"></script>
<script>
    layui.use(['jquery','layer',"form"], function() {
        var $ = layui.jquery, layer = layui.layer,form = layui.form;
        form.on('submit(sub)', function(data){
            $.ajax({
                url : "./deal.php?action=add",
                type : "post",
                data : data.field,
                dataType : "json",
                success : function(res){
                    layer.msg(res.msg);
                    if(res.code == 200){
                        window.setTimeout("window.location='index.html'",2000);
                    }

                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        })


    })
</script>